#if !defined(AFX_REQUESTTHREADPOOL_H__0A12BF7C_0BE5_4DA6_BAC1_D851D8E5EF16__INCLUDED_)
#define AFX_REQUESTTHREADPOOL_H__0A12BF7C_0BE5_4DA6_BAC1_D851D8E5EF16__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// RequestThreadPool.h : header file
//

#define WM_APP_REQUESTTHREADEXITED  (WM_APP+100)
#define WM_APP_EXITTHREAD           (WM_APP+101)

class RequestThread;
class BaseRequestHandler;

/////////////////////////////////////////////////////////////////////////////
// CRequestThreadPool thread

class CRequestThreadPool : public CWinThread
{
	DECLARE_DYNCREATE(CRequestThreadPool)
protected:
	CRequestThreadPool();           // protected constructor used by dynamic creation

	// Attributes
private:
	static CRequestThreadPool * m_pInstance;

	std::list<RequestThread *> m_RequestThreads;

	CMutex m_mutexRequestThreads;

	// Operations
public:
	static CRequestThreadPool * Instance();
	static void DeleteInstance();
	void AddRequest(BaseRequestHandler * pHandler);

	// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CRequestThreadPool)
public:
	virtual BOOL InitInstance();
	virtual int ExitInstance();
	//}}AFX_VIRTUAL

	// Implementation
protected:
	virtual ~CRequestThreadPool();

	// Generated message map functions
	//{{AFX_MSG(CRequestThreadPool)
	// NOTE - the ClassWizard will add and remove member functions here.
	//}}AFX_MSG
	afx_msg LRESULT OnRequestThreadExited(WPARAM wParam, LPARAM lParam);
	afx_msg LRESULT OnExitThread(WPARAM wParam, LPARAM lParam);

	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_REQUESTTHREADPOOL_H__0A12BF7C_0BE5_4DA6_BAC1_D851D8E5EF16__INCLUDED_)
